# -- coding: utf-8 --
from wnboss03.util import UI, FileParser


class Common:

    def __init__(self):
        self.ui = UI
        self.login_set = FileParser.read_json('../locators/login.json')
        self.info = FileParser.read_json('../base.json')

    def do_login(self, uname, upass, url):
        ui = self.ui
        login_set = self.login_set
        info = self.info
        ui.get_driver(info['browser'])
        ui.get(info['login_url'])
        ui.input(login_set['uname'], uname)
        ui.input(login_set['upass'], upass)
        ui.click(login_set['login_button'])
        ui.get(url)

    def do_logout(self):
        self.ui.click(self.login_set['logout_button'])

    def close_window(self):
        self.ui.close()

if __name__ == '__main__':
    pass